/*
 * Copyright (c) 2010-2020 IISI.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of IISI.
 */
package com.iisigroup.log.analysis;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 *
 */
public class TestClass {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		System.out.println(new Date());
 
		//		LocalDate
		SimpleDateFormat sdf = new SimpleDateFormat("a h時m分s秒",Locale.TAIWAN );
		String sample = sdf.format(new Date());
		String sample02 = "####<2014/9/3 上午11時34分56秒 CST> <Error> <WebLogicServer> <RISFLAP1> <SRIS3> <[ACTIVE] ExecuteThread: '4' for queue: 'weblogic.kernel.Default ";
		System.out.println(sample);
		String extractData = Converter.extractTaiwainTime(sample02);
		System.out.println(extractData);
		String sample03 ="/home/weblogic/Desktop/log_sample/WLSLOG/195.1.102.13/SRIS3/SRIS3.log";
		String hostIp = Converter.extractHostIp(sample03);
		System.out.println(hostIp);
		String patternUserId ="userId:.*(R.\\w\\d{6})";
		String userIdSample ="userId: RF0500060";
		
	}
	private static final String clientIpPattern ="(Proxy-Client-IP):.*(\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b)"; 
	
	public String extractClientIp (final String line){
		Matcher matcher = Pattern.compile(clientIpPattern).matcher(line);
		if(matcher.find()){
			String ip = matcher.group(2);
			return ip;
		}else{
			return null;
		}
	}
	//================================================
	//== [Enumeration types] Block Start
	//== [Enumeration types] Block End 
	//================================================
	//== [static variables] Block Start
	//== [static variables] Block Stop 
	//================================================
	//== [instance variables] Block Start
	//== [instance variables] Block Stop 
	//================================================
	//== [static Constructor] Block Start
	//== [static Constructor] Block Stop 
	//================================================
	//== [Constructors] Block Start (含init method)
	//== [Constructors] Block Stop 
	//================================================
	//== [Static Method] Block Start
	//== [Static Method] Block Stop 
	//================================================
	//== [Accessor] Block Start
	//== [Accessor] Block Stop 
	//================================================
	//== [Overrided Method] Block Start (Ex. toString/equals+hashCode)
	//== [Overrided Method] Block Stop 
	//================================================
	//== [Method] Block Start
	//####################################################################
	//## [Method] sub-block : 
	//####################################################################    
	//== [Method] Block Stop 
	//================================================
	//== [Inner Class] Block Start
	//== [Inner Class] Block Stop 
	//================================================
}
